package com.yk.points.service.impl;

import java.util.List;
import com.yk.common.utils.DateUtils;
import com.yk.common.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yk.points.mapper.PointsGoodsMapper;
import com.yk.points.domain.PointsGoods;
import com.yk.points.service.IPointsGoodsService;
import com.yk.common.core.text.Convert;

/**
 * 商品积分Service业务层处理
 * 
 * @author xufei
 * @date 2025-04-28
 */
@Service
public class PointsGoodsServiceImpl implements IPointsGoodsService 
{
    @Autowired
    private PointsGoodsMapper pointsGoodsMapper;

    /**
     * 查询商品积分
     * 
     * @param id 商品积分主键
     * @return 商品积分
     */
    @Override
    public PointsGoods selectPointsGoodsById(Long id)
    {
        return pointsGoodsMapper.selectPointsGoodsById(id);
    }

    /**
     * 查询商品积分列表
     * 
     * @param pointsGoods 商品积分
     * @return 商品积分
     */
    @Override
    public List<PointsGoods> selectPointsGoodsList(PointsGoods pointsGoods)
    {
        return pointsGoodsMapper.selectPointsGoodsList(pointsGoods);
    }

    /**
     * 新增商品积分
     * 
     * @param pointsGoods 商品积分
     * @return 结果
     */
    @Override
    public int insertPointsGoods(PointsGoods pointsGoods)
    {
        pointsGoods.setCreateBy(ShiroUtils.getLoginName());
        pointsGoods.setCreateTime(DateUtils.getNowDate());
        pointsGoods.setDelFlag("0");
        pointsGoods.setStatus("1");
        return pointsGoodsMapper.insertPointsGoods(pointsGoods);
    }

    /**
     * 修改商品积分
     * 
     * @param pointsGoods 商品积分
     * @return 结果
     */
    @Override
    public int updatePointsGoods(PointsGoods pointsGoods)
    {
        pointsGoods.setUpdateTime(DateUtils.getNowDate());
        pointsGoods.setUpdateBy(ShiroUtils.getLoginName());
        return pointsGoodsMapper.updatePointsGoods(pointsGoods);
    }

    /**
     * 批量删除商品积分
     * 
     * @param ids 需要删除的商品积分主键
     * @return 结果
     */
    @Override
    public int deletePointsGoodsByIds(String ids)
    {
        return pointsGoodsMapper.deletePointsGoodsByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除商品积分信息
     * 
     * @param id 商品积分主键
     * @return 结果
     */
    @Override
    public int deletePointsGoodsById(Long id)
    {
        return pointsGoodsMapper.deletePointsGoodsById(id);
    }
}
